<template>
  <div class="icons">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(page,index) of pages" :key="index">
        <div v-for="item of page" :key="item.id" class="icon">
          <img :src="item.imgUrl" alt>
          <p>{{item.title}}</p>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>
<script>
export default {
  name: "HomeIcons",
  props: {
    icons: {
      type: Array
    }
  },
  computed: {
    pages() {
      let pages = [];
      for (let i = 0; i < this.icons.length / 8; i++) {
        pages[i] = this.icons.slice(8 * i, 8 * (i + 1));
      }
      return pages;
    }
  },
  data() {
    return {
      swiperOption: {
        pagination: {
          el: ".swiper-pagination"
        }
      }
    };
  }
};
</script>
<style lang="scss" scoped>
.swiper-slide {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 120px 120px;
  align-items: center;
  justify-items: center;
  text-align: center;
  img {
    width: 70px;
    height: 70px;
  }
  padding-bottom: 10px;
  p{
    font-size: 10px;
  }
}
</style>
